package com.neishenmo.sochatapp.network;



import com.neishenmo.sochatapp.http.RetrofitFactory;

import java.util.Map;

import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import rx.Observable;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * 创建人： wushixin
 * 创建日期：2017/10/26
 * 内容：
 */

public class ApiTask {

    /**
     * 注册
     * */
    public  void getRegistUser(Subscriber<String> subscriber, RequestBody string){
        Observable<String> observable= RetrofitFactory.getInstances().getRetrofit().create(ApiService.class)
                .getRegistUser(string);
        if (observable!=null){
            observable
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(subscriber);
        }

    }
    /**
     * 发送外部验证码（登陆、注册）
     * */
    public  void getSendExternalCode(Subscriber<String> subscriber, RequestBody string){
        Observable<String> observable= RetrofitFactory.getInstances().getRetrofit().create(ApiService.class)
                .getSendExternalCode(string);
        if (observable!=null){
            observable
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(subscriber);
        }

    }
    /**
     * 用户登录
     * */
    public  void getUserLogin(Subscriber<String> subscriber, RequestBody string){
        Observable<String> observable= RetrofitFactory.getInstances().getRetrofit().create(ApiService.class)
                .getSendExternalCode(string);
        if (observable!=null){
            observable
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(subscriber);
        }

    }

}
